Conventionally, a graphics surface is divided into smaller primitives (e.g., triangles). The primitives are rasterized and other operations are performed to generate fragments for visible portions of primitives. Individual fragments are also shaded to generate the fragment color, generate transparencies, and perform other effects. Note that a fragment refers to a portion of a pixel, where a pixel corresponds to a region of the display or image. However, due to the close relationship between fragments and pixels, in the graphics art the term “pixel” is sometimes used equivalently to the term “fragment” in regards to shading operations. In this context, a pixel may be either fully or partially covered.
A graphics pipeline typically includes a pixel shader to shade pixels. A pixel shader converts a set of texture coordinates into a color using a shader program. Note that a pixel shader may also perform other operations and may, for example, accept interpolated inputs and produce general outputs. For example, the DX10 API permits a single pixel to hold as many as 32 values on output. Textures conventionally have horizontal and vertical texture coordinates mapped to an (s, t) space using a plane equation or other interpolation methods. The pixel shading may, for example, be performed using parallel processing units.
Note that in a conventional pixel shading paradigm the shading of primitives is performed largely independent of one another. This permits the processing work to be distributed amongst parallel shading elements until all of the primitives of a frame are shaded. Thus, in a conventional shading paradigm a first primitive is shaded, then another, and so on until all of the primitives of the frame are shaded. One aspect of this shading paradigm is that typically intermediate calculations used to shade pixels of individual primitives are not retained after a particular primitive is shaded. Note that the primitives may also be shaded “side by side” in adjacent shader units. In either case, the intermediate calculations are not available across primitives.
In addition to performing texture operations to calculate a pixel color, a pixel shader may also perform other filtering operations that require calculating an estimate of texture derivatives with respect to neighboring pixels. The derivatives are estimated based on differences in texture values with respect to a neighboring pixel. The texture coordinates may, for example, be calculated at pixel centers in a multi-pixel “footprint.” As one example, the footprint may be a group of four pixels (a “quad”) including the pixel being shaded. Thus, a common algorithm for shading an individual pixel is to select a footprint of pixels about the pixel, determine the texture coordinate at pixel centers in the footprint about the pixel being shaded using an appropriate technique, and estimate texture derivatives for filtering the pixel being shaded.
Additionally, graphics systems often employ multi-sampling techniques to reduce the effects of aliasing. Aliasing effects are generated at the edges of partially covered pixels, because a sharp edge corresponds to an “infinite” frequency such that steps will be visible at edges unless blurred. Aliasing effects commonly generate jagged-looking edges, what are sometimes known as “jaggies.” In multi-sampling each pixel has two or more locations that are sampled for coverage. Conventionally, a single color is calculated per pixel and used for all subpixel samples covered by the primitive.
A problem with conventional pixel shaders is that the efficiency of the shading process tends to decrease as the triangle size shrinks. As the triangle size shrinks, a larger percentage of the pixels are are partially covered edge pixels. For the case of texture derivatives, the decrease in efficiency with decreasing triangle size is caused by the need to calculate neighboring exterior pixels outside of a triangle solely for the purpose of estimating texture derivatives for edge pixels of the triangle. As a result, triangles having a comparatively small size will require a significant number of exterior pixels per interior pixel to be calculated solely for estimating texture derivatives. An analogous problem occurs in regards to the efficiency of calculations performed for multisampling as the triangle size shrinks.
FIG. 1 illustrates a primitive 100 which is to be shaded. An individual pixel 112 has a pixel center within primitive 100 proximate edge 105 such that pixel 112 will be shaded. In order to calculate texture coordinate derivatives for pixel 112, texture values for other pixels 114, 116, and 118 outside of primitive 100 must be calculated as part of a group derivative footprint 110, such as a quad of four pixels. Thus, for a pixel 112 to be shaded, the other pixels 114, 116, and 118 within the group footprint 110 must also be shaded to generate derivative information. For a comparatively large primitive 100 this may not be a concern since the perimeter-to-area ratio is low. However, referring to FIG. 2, for a comparatively small primitive 200, the perimeter-to-area ratio increases. As a result, a large percentage of the pixels will be edge pixels, such as a pixel 212 near edge 205, increasing the fraction of exterior pixels that must be calculated for the sole purpose of generating derivative information. For example, exterior pixels 214, 216, and 218 of quad 210 must be rendered to generate texture derivatives for pixel 212. It can be understood from comparing FIGS. 1 and 2 that as the triangle size shrinks the cost per output pixel goes up because the dummy pixels required to calculate texture derivatives increases.
It can also be understood from comparing FIGS. 1 and 2 that as the triangle size shrinks the computational resources required to perform multi-sampling increases. In multi-sampling the color of the same pixel is calculated twice (or more) once for each sample location within the pixel covered by a different primitive. Referring again to FIG. 1, an individual edge pixel 140 has multi-sample locations 142 and 144. Referring to FIG. 2, edge pixel 240 has multi-sample locations 242 and 244. However, due to the smaller size of primitive 200, a larger fraction of pixels are partially covered pixels than for the case of FIG. 1.
There is an increasing interest in performing graphics processing of complex surfaces. Complex surfaces are best processed by dividing the surface into comparatively small primitives (triangles). However, as previously described, this may result in a large increase in the waste of resources that must be devoted to calculating texture derivatives and for performing multi-sampling.
In light of the above-described problems, the apparatus and system of the present invention was developed.